fix(android): [Data Collection 17] Apply user info policy to distinct ID - #5833
Conversation
Generate the default Android installation ID after programmatic configuration and only when the resolved user information policy allows it. Preserve custom distinct IDs and keep legacy behavior when Data Collection is absent. Refs #5666 Co-Authored-By: Claude <noreply@anthropic.com>
| "Error in the 'OptionsConfiguration.configure' callback.", | ||
| t); | ||
| } | ||
| if (options.getDistinctId() == null |
There was a problem hiding this comment.
Moving this here no longer allows customers to override it in the options configuration callback passed to init since it used to run before but now is set afterwards. It can still be removed via beforeSend. Is that OK?
There was a problem hiding this comment.
Good question, as this is a change in behaviour for existing users. I.e. if they update and have previously set the id to null in order not to track the id, it would be turned back on after updating the sdk. Also, beforeSend doesn't cover logs or metrics, correct?
There was a problem hiding this comment.
This is a leftover, reverting since we decided not to guard Installation.id()
📲 Install BuildsAndroid
|
Performance metrics 🚀
|
…to fix/data-collection-android-installation-id
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
…to fix/data-collection-android-installation-id
…to fix/data-collection-android-installation-id
…to fix/data-collection-android-installation-id
…to fix/data-collection-android-installation-id
…to fix/data-collection-android-installation-id
…to fix/data-collection-android-installation-id
…to fix/data-collection-android-installation-id
This reverts commit b27d61d.\n\nKeep generated installation IDs independent of the userInfo policy. Restore\ndefault generation before programmatic configuration so applications can\ncontinue clearing the distinct ID in the configuration callback.\n\nRefs #5666\n\nCo-Authored-By: Claude <noreply@anthropic.com>
PR Stack (Data Collection)
📜 Description
Apply the resolved user information policy when generating Android's default installation-backed
distinctId.Move default
distinctIdgeneration out ofAndroidOptionsInitializerand run it after the programmaticSentryAndroid.initcallback. Generate the installation ID only when no distinct ID is configured anddataCollection.userInfoallows automatic identity collection.Existing runtime gates in Android event, exit-info, device-context, and hybrid scope enrichment remain unchanged.
💡 Motivation and Context
Android logs and metrics use
distinctIdas an automaticuser.idfallback when no scope user exists. The previous unconditional default generation left that SDK-generated identity available even when applications explicitly configureddataCollection.userInfo=false.Evaluating the policy after the programmatic callback prevents automatic
distinctIdgeneration for opted-out applications while preserving custom IDs and the legacy absent-Data-Collection behavior.Refs #5666
💚 How did you test it?
./gradlew spotlessApply apiDump./gradlew :sentry-android-core:testDebugUnitTest --tests='io.sentry.android.core.AndroidOptionsInitializerTest' --tests='io.sentry.android.core.ApplicationExitInfoEventProcessorTest' --tests='io.sentry.android.core.DeviceInfoUtilTest'./gradlew :sentry-android-core:apiCheck :sentry-android-core:spotlessJavaCheck :sentry-android-core:spotlessKotlinCheckgit diff --check📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Add external and Android manifest Data Collection configuration before finalizing the stack.
#skip-changelog